feat: Pass through and expose additional parameters in ClientSessionGroup.call_tool and .connect_to_server
#1576
+87
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exposed additional optional parameters in the
call_toolandconnect_to_servermethods so that they can fully pass through supported arguments to the underlying session-level methods.Replace the parameter
argsincall_toolwithargumentsso that it's aligned with the originalClientSession.call_toolmethod.Use
@overloadand@deprecatedto markargsas deprecated while still supporting its usage.Motivation and Context
Previously,
call_toolandconnect_to_serverignored several optional parameters supported by the lower-levelClientSessionand session methods.As a result, certain advanced use cases (e.g., custom timeouts, callbacks, or client metadata) could only be supported by directly accessing lower-level APIs, which was cumbersome and inconsistent.
This change:
call_toolfor timeouts, progress tracking, and metadata.session_paramstoconnect_to_serverto configureClientSessioncreation directly.ClientSessionParametersdataclass for clear typing.How Has This Been Tested?
Pyright static type check and pytest.
Breaking Changes
argsparameter incall_toolis deprecated in favor ofarguments.Types of changes
Checklist
Additional context
ClientSessionParametersusesdataclasses.dataclassinstead ofpydantic.BaseModelbecauseBaseModeldoes not supportProtocol-typed fields. Attempts withSkipValidationandarbitrary_types_allowed=Truedid not resolve the issue.